const Koa = require("koa");
const app = new Koa();
const koaRouter = require("koa-router");
const router = new koaRouter();


// app.use(async ctx => {
//     ctx.body = 'Hello World 22222';
//   });

router.get('/',function (ctx) {
    console.log(ctx);
    ctx.body = 'hello world';
});

router.get("/user", async (ctx) => {
    let { body } = ctx.request; // es6的写法把ctx.request请求体的所有方法都放到body对象里面去
    let aa = {};
    aa.status = ctx.request;
    aa.name = body || 'name';
    ctx.body = aa;
});

  app.use(router.routes())
  app.listen(3000);